cmake_minimum_required(VERSION 3.5.0)

set(CMAKE_CXX_STANDARD 11)

project(GenGtkCode)

# MSVC编译器下时，目标路径应该根据CONFIG而定，其他单配置工具，目标路径在cmake调用时确定
if (MSVC)
	set(BUILD_FOLDER $<CONFIG>)
else()
  if (NOT CMAKE_BUILD_TYPE)
    set(BUILD_FOLDER Release)
  else()
    set(BUILD_FOLDER ${CMAKE_BUILD_TYPE})
  endif()
endif()

# 判断一下使用的XML库
if (NOT XML_LIB)
  # 没有定义时，默认使用rapidxml，不需要链接相关库
  set(XML_LIBRARY 4)
else()
  set(XML_LIBRARY ${XML_LIB})
endif()

# 校验XML库的ID
if ( (XML_LIBRARY GREATER 0) AND (XML_LIBRARY LESS 7))
  message("Set XML_LIBRARY: ${XML_LIBRARY}")
else()
  message(FATAL_ERROR "Bad XML_LIBRARY: ${XML_LIBRARY}")
endif()

# 设置操作系统目录名
if (WIN32)
    #if (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64")
    #if (CMAKE_CL_64)
    # 根据指针长度判断是32位编译器还是64位编译器 
    if (CMAKE_SIZEOF_VOID_P EQUAL 8)
        message("Windows 64 Bit.")
        set(LIB_OS_NAME Win64)
    else()
        message("Windows 32 Bit.")
        set(LIB_OS_NAME Win32)
    endif()
elseif (UNIX AND NOT APPLE)
    set(LIB_OS_NAME ${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_PROCESSOR})
else()
    set(LIB_OS_NAME others)
endif()

# 默认安装至源代码的当前路径下
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
# bin路径需要组合编译类型＋系统架构
set(CMAKE_INSTALL_BINDIR bin/${LIB_OS_NAME}/${BUILD_FOLDER})
# lib路径需要组合编译类型＋系统架构
set(PROJECT_LIBRARY_DIR ${CMAKE_SOURCE_DIR}/lib/${LIB_OS_NAME}/${BUILD_FOLDER}/)

add_subdirectory(src/gtkui)
add_subdirectory(src/GenGtkCode)


